package controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpSession;

@Controller
public class IndexController {

    /**
     * 去main页面
     * @return
     */

    @GetMapping("main.html")
    public String mainPage(HttpSession session,Model model){
        Object loginUser = session.getAttribute("loginUser");
        //是否登录的拦截器
        if(loginUser != null){
            return "main";
        }else{
            //回到登录页面
            model.addAttribute("msg","请重新登录");
            return "login";
        }
    }
}
